<?php
/*
	结算明细
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
cfc('core')->checklogin();
if($_RQ['op']=='main'){
	$return['setting']=$this->plugin_setting('page_setting');	
	$return['balance_total']=price($this->sum('balance',array('mid'=>$_SESSION['uid']),'money'));
	$return['params']=array(
		'page'=>1,
		'status'=>3,
	);
	$return['list']=array();
	$return['post']=array('id'=>0);
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('mid'=>$_SESSION['uid']);
	
	$params['status']=intval($_RQ['status']);
	$psize=20;
	$pindex=intval($_RQ['page'])?:1;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		
	);
	$list=$this->get_list('balance',$parameter);
	$paytype=$this->pay_types;
	if(!$list){
		exi('none');
	}
	foreach($list as &$v){
		$v['pay_type']=$paytype[$v['pay_type']];
		$v['pay_time']=date('Y-m-d H:i:s',$v['pay_time']);
	}
	exi($list);
}
if($_RQ['op']=='post'){
	$post=get_postdata();
	$balance_id=intval($post['id']);
	$remark=$post['remark'];
	$update=array(
		'status'=>0,
		'remark'=>$remark,
	);
	$this->update('balance',$update,array('id'=>$balance_id));
	exi('申请成功！','','main');
}
?>